package cn.xinfei.xdecision.common.vo;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@Data
public class FieldInfoVo {
    private String fieldName;
    private String fieldCode;
    //变量存值类型,待选(0),integer(1),string(2),boolean(3),double(4)
    private Integer valueType;
    //"1","基础变量","2","常变量","3","数据库变量","4","衍生变量","5","接口变量"
    private String varTypeId;
    private Object varDefaultValue;
    private Object constValue;
    private int isInput = 0;

    private int isOutput = 0;
    private int isInner = 0;

    //变量类型 java(J),python(P),model(M),credit(C),standard(S)
    private String sourceType;

    /**
     * 冗余一个字段
     * 当是从规则组件实例中解析出的变量时，存储规则code
     */
    private String ruleCode;

    /**
     * 1输ru
     * 2过程
     * 3输出
     */
    public int getStage() {
        if (isInput == 1) {
            return 1;
        }
        if (isInner == 1) {
            return 2;
        }
        if (isOutput == 1) {
            return 3;
        }
//        log.error("getState error. field={}", this);
        return 0;
    }

    public void setDefaultValue(Object defaultValue) {
        this.varDefaultValue = defaultValue;
    }

    public void setVarDefaultValue(Object varDefaultValue) {
        this.varDefaultValue = varDefaultValue;
    }
}
